package com.monkey.config;

import com.monkey.interceptor.SqlBeautyInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 将自己定义的mybatis的优化器交给spring容器管理
 */
@Configuration
public class MybatisConfiguration {
    /**
     * 往mybatis注入sql优化器
     * @return
     */
    @Bean
    @ConditionalOnProperty(name = {"sql.beauty.show"},havingValue = "true",matchIfMissing = true)
    public SqlBeautyInterceptor creatSqlBeautyInterceptor(){
        return new SqlBeautyInterceptor();
    }
}
